package com.mallcai.bigdata.ladon.controller.report.form;

import com.mallcai.bigdata.ladon.controller.BaseForm;
import com.mallcai.bigdata.ladon.dpl.entity.report.Group;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * Created by oneape<oneape15@163.com>
 * Created 2019-07-09 11:02.
 * Modify:
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class GroupForm extends BaseForm {
    @NotNull(message = "主键不能为空", groups = {IdCheck.class, EditCheck.class})
    private Long    groupId;  // 组Id
    @NotNull(message = "父节点Id不能为空", groups = {AddCheck.class, EditCheck.class})
    private Long    parentId; // 父级节点Id, 默认为0
    @NotBlank(message = "报表组名称不能为空", groups = {AddCheck.class, EditCheck.class})
    private String  name;     // 报表组名
    private String  comment;  // 描述信息
    private String  icon;     // 报表组图标
    private Integer level;    // 所在层级, 从1开始
    private Long    sortId;   // 排序Id

    public interface IdCheck {
    }

    public interface AddCheck {
    }

    public interface EditCheck {
    }

    public Group toEntity() {
        Group g = new Group();
        g.setId(groupId);
        g.setParentId(parentId);
        g.setName(name);
        g.setIcon(icon);
        g.setLevel(level);
        g.setSortId(sortId);
        g.setComment(comment);
        return g;
    }

}
